package network

import (
	"fmt"
	"github.com/spf13/cobra"
)

func GetNetworkListCmd() *cobra.Command {
	return &cobra.Command{
		Use:   "list",
		Short: "list all networks",
		Long:  `list all networks your have created`,
		Args:  cobra.MinimumNArgs(0),
		Run:   networkList,
	}
}

func networkList(cmd *cobra.Command, args []string) {
	if len(args) > 0 {
		_ = cmd.Help()
	}

	err := Init()
	if err != nil {
		fmt.Println("failed to init network module :", err.Error())
		return
	}
	listNetwork()
}
